﻿<%@ Page Title="" Language="C#" MasterPageFile="~/default.Master" AutoEventWireup="true" CodeBehind="AccountManagement.aspx.cs" Inherits="DelonixRegia.AccountManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphPageTitle" runat="server">
    Account Management - Delonix Regia
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="cphTitle" runat="server">
    <i class="fa fa-cog"></i> Account Management
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphSubtitle" runat="server">
    Account Management for Counter-Receptionist
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="cphMain" runat="server">
    <div class="panel panel-default" style="width: 800px; margin: 0 auto;">
        <div class="panel-heading">
            Account Management
        </div>

        <div class="panel-body">
            <div class="alert alert-danger" id="errorBox" style="display: none;">
            </div>
            <div class="alert alert-success" id="successBox" style="display: none;">
            </div>
            <div class="text-center"><strong>Create new Receptionist Account</strong></div><br />

            <table class="nav-justified" style="width: 430px; margin: 0 auto;">
                <tr>
                    <td class="text-right" style="width: 151px">Username:</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>
                        <asp:TextBox ID="tbxUsername" runat="server" CssClass="form-control" Width="145px" MaxLength="30"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td style="width: 151px">&nbsp;</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="text-right" style="width: 151px">Password:</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>
                        <asp:TextBox ID="tbxPassword" runat="server" CssClass="form-control" Width="145px" TextMode="Password"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="text-right" style="width: 151px">Repeat Password:</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>
                        <asp:TextBox ID="tbxPasswordAgn" runat="server" CssClass="form-control" Width="145px" TextMode="Password"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td style="width: 151px">&nbsp;</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="text-right" style="width: 151px">Contact Number:</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>
                        <asp:TextBox ID="tbxContact" runat="server" CssClass="form-control" Width="170px" MaxLength="8"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="text-right" style="width: 151px">Email Address:</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>
                        <asp:TextBox ID="tbxEmail" runat="server" CssClass="form-control" Width="200px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td style="width: 151px">&nbsp;</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="text-right" style="width: 151px">Permissions:</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>
                        <asp:DropDownList ID="ddlDuty" runat="server" CssClass="form-control" Width="145px">
                            <asp:ListItem>Not Selected</asp:ListItem>
                            <asp:ListItem Value="1">Receptionist</asp:ListItem>
                            <asp:ListItem Value="2">Manager</asp:ListItem>
                            <asp:ListItem Value="3">Administrator</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td style="width: 151px">&nbsp;</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="3" class="text-center">
                        <asp:Button ID="btnCreate" runat="server" Text="Create" CssClass="btn btn-default btn-lg" OnClientClick="return verifyCreate();" OnClick="btnCreate_Click" />
                    </td>
                </tr>
            </table>
            
        </div>
    </div>

    <script type="text/javascript">
        function verifyCreate() {
            var username = $('#cphMain_tbxUsername').val();
            var password = $('#cphMain_tbxPassword').val();
            var passwordAgn = $('#cphMain_tbxPasswordAgn').val();
            var contact = $('#cphMain_tbxContact').val();
            var email = $('#cphMain_tbxEmail').val();
            var dutyType = $('#cphMain_ddlDuty').val();

            if ((username.length == 0) || (password.length == 0) || (passwordAgn.length == 0) || (contact.length == 0) || (email.length == 0) || (dutyType == "Not Selected")) {
                $('#errorBox').html('<strong>Error:</strong> All fields are required! Please check and try again.');
                $('#errorBox').hide().show();
                return false;
            }

            if (password != passwordAgn) {
                $('#errorBox').html('<strong>Error:</strong> Passwords do not match!');
                $('#errorBox').hide().show();
                $('#cphMain_tbxPassword').focus();
                return false;
            }
        }

        $('#cphMain_tbxUsername').keydown(errorBoxHide);
        $('#cphMain_tbxPassword').keydown(errorBoxHide);
        $('#cphMain_tbxPasswordAgn').keydown(errorBoxHide);
        $('#cphMain_tbxContact').keydown(errorBoxHide);
        $('#cphMain_tbxEmail').keydown(errorBoxHide);
        $('#cphMain_ddlDuty').change(errorBoxHide);

        function errorBoxHide() {
            $('#errorBox').hide();
            $('#successBox').hide();
        }
    </script>
</asp:Content>
